﻿<UserControl x:Class="Kokomo.PeInspector.Reflection.AssemblyExporterView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:env="xaml://kokomo/environment"
			 xmlns:pe="clr-namespace:Kokomo.PeInspector"
             mc:Ignorable="d" 
			 xmlns:r="clr-namespace:Kokomo.PeInspector.Reflection"
             d:DesignHeight="300" d:DesignWidth="300">
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>
		<Border
			Style="{DynamicResource {x:Static env:EditorStyleKeys.SectionBorderStyleKey}}"
			>
			<StackPanel
				IsEnabled="{Binding IsInputEnabled}"
				>
				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition Width="Auto"/>
					</Grid.ColumnDefinitions>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
					</Grid.RowDefinitions>
					<Grid.Resources>
						<Style TargetType="TextBox">
							<Setter Property="HorizontalAlignment" Value="Left"/>
							<Setter Property="Margin" Value="3"/>
						</Style>
						<Style TargetType="ComboBox">
							<Setter Property="HorizontalAlignment" Value="Left"/>
							<Setter Property="Margin" Value="3"/>
						</Style>
						<Style TargetType="TextBlock">
							<Setter Property="VerticalAlignment" Value="Center"/>
							<Setter Property="Margin" Value="3"/>
						</Style>
					</Grid.Resources>

					<TextBlock Text="{x:Static pe:Messages.OutputDirectoryLabel}"/>
					<TextBox Grid.Column="1" Width="300" Text="{Binding OutputDirectory}"/>
					<Button Grid.Column="2" Content="..." Command="{Binding BrowseOutputPathCommand}"/>

					<TextBlock Grid.Row="1" Text="{x:Static pe:Messages.ProjectFileFormatLabel}"/>
					<ComboBox
						Grid.Row="1"
						Grid.Column="1"
						Width="150"
						SelectedItem="{Binding SelectedProjectFormat}"
						ItemsSource="{Binding ProjectFormats}"
						/>
				</Grid>

				<GroupBox Header="Options" Margin="6" HorizontalAlignment="Left">
					<StackPanel>
						<CheckBox Content="Include resources" IsChecked="{Binding IncludeResources}"/>
						<CheckBox Content="Open project on completion" IsChecked="{Binding OpenProjectOnComplete}"/>
					</StackPanel>
				</GroupBox>

				<Button HorizontalAlignment="Left" Content="Export" Command="{Binding ExportCommand}"/>
			</StackPanel>
		</Border>

		<Border
			Style="{DynamicResource {x:Static env:EditorStyleKeys.SectionBorderStyleKey}}"
			Grid.Row="1"
			Margin="0 6 0 0"
			>

			<Grid>
				<ContentPresenter Content="{Binding ExportProgress}" VerticalAlignment="Top"/>

				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="*"/>
					</Grid.RowDefinitions>
					<Grid>
						<Grid.Style>
							<Style TargetType="Grid">
								<Style.Triggers>
									<DataTrigger Binding="{Binding Result}" Value="{x:Null}">
										<Setter Property="Visibility" Value="Collapsed"/>
									</DataTrigger>
								</Style.Triggers>
							</Style>
						</Grid.Style>
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto"/>
							<RowDefinition Height="Auto"/>
							<RowDefinition Height="Auto"/>
						</Grid.RowDefinitions>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="Auto"/>
							<ColumnDefinition Width="6"/>
							<ColumnDefinition Width="Auto"/>
						</Grid.ColumnDefinitions>

						<TextBlock Text="Output directory:" FontWeight="Bold"/>
						<TextBlock Grid.Column="2">
							<Hyperlink Command="{Binding OpenProjectFileCommand}" CommandParameter="{Binding Result.OutputDirectory}">
								<Run Text="{Binding Result.OutputDirectory, Mode=OneWay}"/>
							</Hyperlink>
						</TextBlock>

						<TextBlock Grid.Row="1" Text="Project file:" FontWeight="Bold"/>
						<TextBlock Grid.Row="1" Grid.Column="2">
							<Hyperlink Command="{Binding OpenProjectFileCommand}" CommandParameter="{Binding Result.ProjectFilePath}">
								<Run Text="{Binding Result.ProjectFilePath, Mode=OneWay}"/>
							</Hyperlink>
						</TextBlock>

						<TextBlock Grid.Row="2" Text="Assembly info file:" FontWeight="Bold"/>
						<TextBlock Grid.Row="2" Grid.Column="2">
							<Hyperlink Command="{Binding OpenProjectFileCommand}" CommandParameter="{Binding Result.AssemblyInfoPath}">
								<Run Text="{Binding Result.AssemblyInfoPath, Mode=OneWay}"/>
							</Hyperlink>
						</TextBlock>
					</Grid>

					<ScrollViewer Grid.Row="1" Margin="0 6 0 0">
						<ItemsControl
							ItemsSource="{Binding DetailViewModels}"
							Grid.IsSharedSizeScope="True"
							>
							<ItemsControl.ItemTemplate>
								<DataTemplate DataType="{x:Type r:AssemblyExporterResultDetailViewModel}">
									<Grid>
										<Grid.ColumnDefinitions>
											<ColumnDefinition SharedSizeGroup="Icon"/>
											<ColumnDefinition SharedSizeGroup="Text"/>
											<ColumnDefinition Width="6"/>
											<ColumnDefinition/>
										</Grid.ColumnDefinitions>

										<Image Source="{Binding IconSource}" Width="16" Height="16"/>
										<ContentPresenter Grid.Column="1" Content="{Binding}">
											<ContentPresenter.Style>
												<Style TargetType="{x:Type ContentPresenter}">
													<Setter Property="ContentTemplate">
														<Setter.Value>
															<DataTemplate DataType="{x:Type r:AssemblyExporterResultDetailViewModel}">
																<TextBlock>
																	<Hyperlink
																		Command="{Binding ItemCommand}"
																		CommandParameter="{Binding ItemCommandParameter}"
																		>
																		<Run Text="{Binding ItemText, Mode=OneWay}"/>
																	</Hyperlink>
																</TextBlock>
															</DataTemplate>
														</Setter.Value>
													</Setter>
													<Style.Triggers>
														<DataTrigger Binding="{Binding ItemCommand}" Value="{x:Null}">
															<Setter Property="ContentTemplate">
																<Setter.Value>
																	<DataTemplate DataType="{x:Type r:AssemblyExporterResultDetailViewModel}">
																		<TextBlock Text="{Binding ItemText}"/>
																	</DataTemplate>
																</Setter.Value>
															</Setter>
														</DataTrigger>
													</Style.Triggers>
												</Style>
											</ContentPresenter.Style>
										</ContentPresenter>

										<TextBlock Grid.Column="3">
											<Hyperlink Command="{Binding OpenFileCommand}">
												<Run Text="{Binding RelativeFileName, Mode=OneWay}"/>
											</Hyperlink>
										</TextBlock>
									</Grid>
								</DataTemplate>
							</ItemsControl.ItemTemplate>
						</ItemsControl>
					</ScrollViewer>
				</Grid>
			</Grid>
		</Border>
	</Grid>
</UserControl>
